# -*- coding: utf-8 -*-
#
# The Philatelist program is a fork of the OpenNumismat program
# Copyright (c) 2011 - 2024 Vitaly Ignatov (OpenNumismat) <opennumismat@gmail.com>
# Copyright (c) 2021 - 2024 Victor Nabatov (Philatelist) <nabatov.victor@gmail.com>
#

import shutil
import tempfile

__path = None
__prefix = ''


def init(prefix):
    global __prefix

    __prefix = prefix


def path():
    global __path

    if not __path:
        __path = tempfile.mkdtemp(prefix=__prefix)

    return __path


def remove():
    global __path

    if __path:
        shutil.rmtree(__path, True)
        __path = None
